﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BlackList.Model
{
    public class YiYeSearchConfigInfo
    {
        public DateTime Start { set; get; } = DateTime.Now;
        public DateTime End { set; get; } = DateTime.Now;
    }
    public class YiYeSearchConfigMgr
    {
        public static YiYeSearchConfigInfo Get()
        {
            YiYeSearchConfigInfo obj = null;
            try
            {
                string fn = Path.Combine(Application.StartupPath, "YiYeSearchConfig.dll");
                if (File.Exists(fn))
                {
                    string json = File.ReadAllText(fn);
                    obj = JsonConvert.DeserializeObject<YiYeSearchConfigInfo>(json);
                    return obj;
                }
            }
            catch { }
            if (obj == null) { obj = new YiYeSearchConfigInfo(); }
            return obj;
        }

        public static void Set(YiYeSearchConfigInfo info)
        {
            try
            {
                string fn = Path.Combine(Application.StartupPath, "YiYeSearchConfig.dll");
                {
                    string json = JsonConvert.SerializeObject(info);
                    File.WriteAllText(fn, json);
                }
            }
            catch { }
        }
    }
}
